package STO_26;

import LCommon.TreeNode;

public class Solution {
	public boolean isSubStructure(TreeNode A, TreeNode B) {
		return A!=null&&B!=null?reCur(A,B)||isSubStructure(A.left, B)||isSubStructure(A.right, B):false;
	}

	private boolean reCur(TreeNode a, TreeNode b) {
		if (b==null) {
			return true;
		}
		if (a==null||a.val!=b.val) {
			return false;
		}
		return reCur(a.left, b.left)&&reCur(a.right, b.right);
	}
}
